import fetch from 'utils/fetch';

// 添加动态
export function insertDynamic(client, content,pic,linkName,urlType,link,htmlContent) {
    const data = {
        client, 
        content,
        pic,
        linkName,
        urlType,
        link,
        htmlContent
    };
    return fetch({
        url: '/official/insertDynamic',
        method: 'post',
        data
    });
}

// 分页查询官方动态

export function pageDynamicByCondition(page, rows,content,client,status,startTime,endTime,sortClickNum,sortCommentNum) {
    const data = {
        page, 
        rows,
        content,
        client,
        status,
        startTime,
        endTime,
        sortClickNum,
        sortCommentNum
    };
    return fetch({
        url: '/official/pageDynamicByCondition',
        method: 'post',
        data
    });
}

// 查看动态
export function getDynamic(pId) {
    const data = {
        pId
    };
    return fetch({
        url: '/official/getDynamic',
        method: 'post',
        data
    });
}

// 修改动态
export function updateDynamic(pId, client,content,pic,linkName,urlType,link,htmlContent) {
    const data = {
        pId, 
        client,
        content,
        pic,
        linkName,
        urlType,
        link,
        htmlContent
    };
    return fetch({
        url: '/official/updateDynamic',
        method: 'post',
        data
    });
}

// 删除动态
export function removeDynamic(pId) {
    const data = {
        pId
    };
    return fetch({
        url: '/official/removeDynamic',
        method: 'post',
        data
    });
}

// 发布动态
export function uploadDynamic(pId) {
    const data = {
        pId
    };
    return fetch({
        url: '/official/uploadDynamic',
        method: 'post',
        data
    });
}

// 分页查询评论
export function pageDynamicComment(page, rows,pId,commentName,status,startTime,endTime) {
    const data = {
        page, 
        rows,
        pId,
        commentName,
        status,
        startTime,
        endTime
    };
    return fetch({
        url: '/official/pageDynamicComment',
        method: 'post',
        data
    });
}

// 批量隐藏
export function hideDynamicComment(commentId, hide) {
    const data = {
        commentId, 
        hide
    };
    return fetch({
        url: '/official/hideDynamicComment',
        method: 'post',
        data
    });
}

// 回复
export function replyDynamicComment(commentContent,pId,commentUserId,commentName,userType) {
    const data = {
        commentContent,
        pId,
        commentUserId,
        commentName,
        userType
    };
    return fetch({
        url: '/official/replyDynamicComment',
        method: 'post',
        data
    });
}